package com.rao.travel.service.impl;

import com.rao.travel.dao.PermissionDao;
import com.rao.travel.pojo.Permission;
import com.rao.travel.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Srao
 * @version 1.0
 * @className PermissionServiceImpl
 * @date 2019/11/5 10:25
 * @package com.rao.travel.service.impl
 * @description
 */
@Transactional
@Service
public class PermissionServiceImpl implements PermissionService {

    @Autowired
    private PermissionDao permissionDao;

    /*查询所有权限*/
    @Override
    public List<Permission> findAll() {
        return permissionDao.findAll();
    }

    /*保存权限*/
    @Override
    public void save(Permission permission) {
        permissionDao.save(permission);
    }

    /*查看权限详情*/
    @Override
    public Permission findById(String id) {
        return permissionDao.findById(id);
    }

    /*删除权限*/
    @Override
    public void deleteById(String id) {
        /*要删除两张表中的权限*/
        /*删除role_permission中的权限*/
        permissionDao.deleteFromRolePermission(id);

        /*删除permission中的权限*/
        permissionDao.deleteFromPermission(id);
    }
}
